#coding=utf-8

#下载交易当天的某一时刻的价格，存入数据库rpcache表

from stockdb.misc import *
import sdsource.web.sina as sina

cs = get_stcodes()
ps = sina.get_rtprices2(cs)
print '完成%i个实时数据取得.'%len(ps)

for p in ps:
    rp = RTPrice()
    
    s = find_stock(p.code)
    rp.stock = s
    
    rp.time = p.time
    
    rp.open = p.open
    rp.lowest = p.lowest
    rp.highest = p.highest
    rp.now = p.now
    
    rp.jump = p.jump
    rp.change = p.change
    
    rp.volume = p.volume
    rp.amount = p.amount
    
    sess.save(rp)

sess.commit()
    
